<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	<meta name="keywords" content="Nacos,Docker" />
	<meta name="description" content="Nacos Docker 快速开始" />
	<!-- 网页标签标题 -->
	<title>Nacos Docker 快速开始</title>
	<link rel="shortcut icon" href="https://img.alicdn.com/tfs/TB1hgJpHAPoK1RjSZKbXXX1IXXa-64-64.png"/>
	<link rel="stylesheet" href="/build/documentation.css" />
</head>
<body>
	<div id="root"><div class="documentation-page" data-reactroot=""><header class="header-container header-container-normal"><div class="header-body"><a href="/zh-cn/index.html"><img class="logo" src="/img/nacos_colorful.png"/></a><div class="search search-normal"><span class="icon-search"></span></div><span class="language-switch language-switch-normal">En</span><div class="header-menu"><img class="header-menu-toggle" src="/img/menu_gray.png"/><ul><li class="menu-item menu-item-normal"><a href="/zh-cn/index.html">首页</a></li><li class="menu-item menu-item-normal menu-item-normal-active"><a href="/zh-cn/docs/what-is-nacos.html">文档</a></li><li class="menu-item menu-item-normal"><a href="/zh-cn/blog/index.html">博客</a></li><li class="menu-item menu-item-normal"><a href="/zh-cn/community/index.html">社区</a></li><li class="menu-item menu-item-normal"><a href="https://cn.aliyun.com/product/aliware/mse?spm=nacos-website.topbar.0.0.0">企业版Nacos</a><img class="menu-img" src="https://img.alicdn.com/tfs/TB1esl_m.T1gK0jSZFrXXcNCXXa-200-200.png"/></li><li class="menu-item menu-item-normal"><a href="http://console.nacos.io/nacos/index.html">控制台样例</a></li></ul></div></div></header><div class="bar"><div class="bar-body"><img src="/img/docs.png" class="front-img"/><div class="bar-title"><span>Nacos 文档</span><div class="bone bone-light"></div></div><img src="/img/docs.png" class="back-img"/></div></div><section class="content-section"><div class="content-body"><div class="sidemenu"><div class="sidemenu-toggle"><img src="https://img.alicdn.com/tfs/TB1E6apXHGYBuNjy0FoXXciBFXa-200-200.png"/></div><ul><li class="menu-item menu-item-level-1"><span>Nacos </span><ul><li style="height:180px;overflow:hidden" class="menu-item menu-item-level-2"><span>Nacos是什么?<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/what-is-nacos.html" target="_self">Nacos简介</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/concepts.html" target="_self">概念</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/architecture.html" target="_self">架构</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/feature-list.html" target="_self">功能和需求列表</a></li></ul></li><li style="height:324px;overflow:hidden" class="menu-item menu-item-level-2"><span>快速开始<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/quick-start.html" target="_self">Nacos</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/quick-start-spring.html" target="_self">Nacos Spring</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/quick-start-spring-boot.html" target="_self">Nacos Spring Boot</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/quick-start-spring-cloud.html" target="_self">Nacos Spring Cloud</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/quick-start-docker.html" target="_self">Nacos Docker</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/use-nacos-with-dubbo.html" target="_self">Nacos Dubbo</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/use-nacos-with-kubernetes.html" target="_self">Nacos k8s</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/nacos-sync.html" target="_self">Nacos Sync</a></li></ul></li><li style="height:252px;overflow:hidden" class="menu-item menu-item-level-2"><span>用户指南<img style="transform:rotate(0deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/sdk.html" target="_self">Java的SDK</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/other-language.html" target="_self">其他语言的SDK</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/open-api.html" target="_self">Open-API指南</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/nacos-spring.html" target="_self">Nacos Spring</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/system-configurations.html" target="_self">Nacos系统参数介绍</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/faq.html" target="_self">FAQ</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>运维指南<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/deployment.html" target="_self">部署手册</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/cluster-mode-quick-start.html" target="_self">集群部署说明</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/management-api.html" target="_self">运维API</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/console-guide.html" target="_self">控制台手册</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/monitor-guide.html" target="_self">监控手册</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/nacos-config-benchmark.html" target="_self">服务配置模块压测报告</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/nacos-naming-benchmark.html" target="_self">服务发现模块压测报告</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/nacos-sync-use.html" target="_self">其他环境迁移到Nacos</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>开源共建<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/contributing.html" target="_self">贡献源码</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/contributing-flow.html" target="_self">贡献流程</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/pull-request.html" target="_self">pull request模板</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/how-to-reporting-bugs.html" target="_self">如何提交问题报告</a></li></ul></li><li style="height:36px;overflow:hidden" class="menu-item menu-item-level-2"><span>社区<img style="transform:rotate(-90deg)" class="menu-toggle" src="/img/arrow_down.png"/></span><ul><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/community.html" target="_self">社区</a></li><li class="menu-item menu-item-level-3"><a href="/zh-cn/docs/nacos-dev.html" target="_self">开发团队</a></li></ul></li></ul></li></ul></div><div class="doc-content markdown-body"><h1>Nacos Docker 快速开始</h1>
<h2>操作步骤</h2>
<ul>
<li>
<p>Clone 项目</p>
<pre><code class="language-powershell">git clone https://github.com/nacos<span class="hljs-literal">-group</span>/nacos<span class="hljs-literal">-docker</span>.git
cd nacos<span class="hljs-literal">-docker</span>
</code></pre>
</li>
<li>
<p>单机模式 Derby</p>
<pre><code class="language-powershell">docker<span class="hljs-literal">-compose</span> <span class="hljs-operator">-f</span> example/standalone<span class="hljs-literal">-derby</span>.yaml up
</code></pre>
</li>
<li>
<p>单机模式 Mysql</p>
<pre><code class="language-powershell">docker<span class="hljs-literal">-compose</span> <span class="hljs-operator">-f</span> example/standalone<span class="hljs-literal">-mysql</span>.yaml up
</code></pre>
</li>
<li>
<p>集群模式</p>
<pre><code class="language-powershell">docker<span class="hljs-literal">-compose</span> <span class="hljs-operator">-f</span> example/cluster<span class="hljs-literal">-hostname</span>.yaml up 
</code></pre>
</li>
<li>
<p>服务注册</p>
<pre><code class="language-powershell">curl <span class="hljs-literal">-X</span> POST <span class="hljs-string">'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&amp;ip=20.18.7.10&amp;port=8080'</span>
</code></pre>
</li>
<li>
<p>服务发现</p>
<pre><code class="language-powershell">curl <span class="hljs-literal">-X</span> GET <span class="hljs-string">'http://127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.naming.serviceName'</span>
</code></pre>
</li>
<li>
<p>发布配置</p>
<pre><code class="language-powershell">curl <span class="hljs-literal">-X</span> POST <span class="hljs-string">"http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&amp;group=test&amp;content=helloWorld"</span>
</code></pre>
</li>
<li>
<p>获取配置</p>
<pre><code class="language-powershell">  curl <span class="hljs-literal">-X</span> GET <span class="hljs-string">"http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&amp;group=test"</span>
</code></pre>
</li>
<li>
<p>Nacos 控制台</p>
<p>link：<a href="http://127.0.0.1:8848/nacos/">http://127.0.0.1:8848/nacos/</a></p>
</li>
</ul>
<h2>Common property configuration</h2>
<table>
<thead>
<tr>
<th>name</th>
<th>description</th>
<th>option</th>
</tr>
</thead>
<tbody>
<tr>
<td>MODE</td>
<td>cluster模式/standalone模式</td>
<td>cluster/standalone default <strong>cluster</strong></td>
</tr>
<tr>
<td>NACOS_SERVERS</td>
<td>nacos cluster地址</td>
<td>eg. ip1,ip2,ip3</td>
</tr>
<tr>
<td>PREFER_HOST_MODE</td>
<td>是否支持hostname</td>
<td>hostname/ip default <strong>ip</strong></td>
</tr>
<tr>
<td>NACOS_SERVER_PORT</td>
<td>nacos服务器端口</td>
<td>default <strong>8848</strong></td>
</tr>
<tr>
<td>NACOS_SERVER_IP</td>
<td>多网卡下的自定义nacos服务器IP</td>
<td></td>
</tr>
<tr>
<td>SPRING_DATASOURCE_PLATFORM</td>
<td>standalone 支持 mysql</td>
<td>mysql / empty default empty</td>
</tr>
<tr>
<td>MYSQL_MASTER_SERVICE_HOST</td>
<td>mysql 主节点host</td>
<td></td>
</tr>
<tr>
<td>MYSQL_MASTER_SERVICE_PORT</td>
<td>mysql 主节点端口</td>
<td>default : <strong>3306</strong></td>
</tr>
<tr>
<td>MYSQL_MASTER_SERVICE_DB_NAME</td>
<td>mysql 主节点数据库</td>
<td></td>
</tr>
<tr>
<td>MYSQL_MASTER_SERVICE_USER</td>
<td>数据库用户名</td>
<td></td>
</tr>
<tr>
<td>MYSQL_MASTER_SERVICE_PASSWORD</td>
<td>数据库密码</td>
<td></td>
</tr>
<tr>
<td>MYSQL_SLAVE_SERVICE_HOST</td>
<td>mysql从节点host</td>
<td></td>
</tr>
<tr>
<td>MYSQL_SLAVE_SERVICE_PORT</td>
<td>mysql从节点端口</td>
<td>default :3306</td>
</tr>
<tr>
<td>MYSQL_DATABASE_NUM</td>
<td>数据库数量</td>
<td>default :2</td>
</tr>
<tr>
<td>JVM_XMS</td>
<td>-Xms</td>
<td>default :2g</td>
</tr>
<tr>
<td>JVM_XMX</td>
<td>-Xmx</td>
<td>default :2g</td>
</tr>
<tr>
<td>JVM_XMN</td>
<td>-Xmn</td>
<td>default :1g</td>
</tr>
<tr>
<td>JVM_MS</td>
<td>-XX:MetaspaceSize</td>
<td>default :128m</td>
</tr>
<tr>
<td>JVM_MMS</td>
<td>-XX:MaxMetaspaceSize</td>
<td>default :320m</td>
</tr>
<tr>
<td>NACOS_DEBUG</td>
<td>开启远程调试</td>
<td>y/n default :n</td>
</tr>
<tr>
<td>TOMCAT_ACCESSLOG_ENABLED</td>
<td>server.tomcat.accesslog.enabled</td>
<td>default :false</td>
</tr>
</tbody>
</table>
<h2>Nacos + Grafana + Prometheus</h2>
<p>参考：<a href="https://nacos.io/zh-cn/docs/monitor-guide.html">Nacos监控指南</a></p>
<p><strong>Note</strong>:  grafana创建一个新数据源时，数据源地址必须是 <strong><a href="http://prometheus:9090">http://prometheus:9090</a></strong></p>
<h2>相关项目</h2>
<ul>
<li><a href="https://github.com/alibaba/nacos">Nacos</a></li>
<li><a href="https://github.com/nacos-group/nacos-docker">Nacos Docker</a></li>
</ul>
</div></div></section><footer class="footer-container"><div class="footer-body"><img src="/img/nacos_gray.png"/><div class="cols-container"><div class="col col-12"><h3>愿景</h3><p>Nacos 通过提供简单易用的动态服务发现、服务配置、服务共享与管理等服务基础设施，帮助用户在云原生时代，在私有云、混合云或者公有云等所有云环境中，更好的构建、交付、管理自己的微服务平台，更快的复用和组合业务服务，更快的交付商业创新的价值，从而为用户赢得市场。</p></div><div class="col col-6"><dl><dt>文档</dt><dd><a href="/zh-cn/docs/what-is-nacos.html" target="_self">概览</a></dd><dd><a href="/zh-cn/docs/quick-start.html" target="_self">快速开始</a></dd><dd><a href="/zh-cn/docs/contributing.html" target="_self">开发者指南</a></dd></dl></div><div class="col col-6"><dl><dt>资源</dt><dd><a href="/zh-cn/community/index.html" target="_self">社区</a></dd><dd><a href="https://www.aliyun.com/product/acm?source_type=nacos_pc_20181219" target="_self">云服务 ACM</a></dd><dd><a href="https://www.aliyun.com/product/edas?source_type=nacos_pc_20181219" target="_self">云服务 EDAS</a></dd><dd><a href="https://www.aliyun.com/product/ahas?source_type=nacos_pc_20190225" target="_self">云服务 AHAS</a></dd></dl></div></div><div class="copyright"><span>@ 2018 The Nacos Authors | An Alibaba Middleware (Aliware) Project</span></div></div></footer></div></div>
	<script src="https://f.alicdn.com/react/15.4.1/react-with-addons.min.js"></script>
	<script src="https://f.alicdn.com/react/15.4.1/react-dom.min.js"></script>
	<script>
		window.rootPath = '';
  </script>
	<script src="/build/documentation.js"></script>
</body>
</html>